import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';


function render(props) {
    const { container } = props;
    const app = createApp(App);
    app.use(router).mount(container instanceof Element
        ? (container.querySelector("#app"))
        : (container)
    );
}
console.log(qiankunWindow)
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
    console.log('不是qiankun',qiankunWindow);
    render({ container: "#app" });
} else {
    renderWithQiankun({
        mount(props) {
            console.log('--mount');
            render(props)
        },
        bootstrap() {
            console.log('--bootstrap');
        },
        update() {
            console.log('--update');
        },
        unmount() {
            console.log('--unmount');
            app?.unmount();
        }
    });
}
